{
  "properties" : { },
  "id" : "88097fd6f745418db97007e4b1590d54",
  "script" : null,
  "groupId" : "43da313fdeaa495798cf783e6cf83479",
  "name" : "查询IP资源列表",
  "createTime" : 1727070855265,
  "updateTime" : 1726046007390,
  "lock" : "1",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "page",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n   \r\n   \r\n    \"groupId\": \"cba03f89025a42f9bf6a3c191eaed231\",\r\n \"size\":10,\r\n \"current\":1,\r\n    \"ipType\": \"26\"\r\n   \r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": {\n        \"total\": 1026,\n        \"current\": 1,\n        \"size\": 10,\n        \"records\": [\n            {\n                \"rtgateway\": \"1.1.3.0\",\n                \"rtusedcount\": \"/62\",\n                \"allocationStatus\": \"\",\n                \"nrtgateway\": \"61.101.3.0\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"1\"\n            },\n            {\n                \"rtgateway\": \"61.100.0.0\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.0.0\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"2\"\n            },\n            {\n                \"rtgateway\": \"61.100.0.64\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.0.64\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"3\"\n            },\n            {\n                \"rtgateway\": \"61.100.0.128\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.0.128\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"4\"\n            },\n            {\n                \"rtgateway\": \"61.100.0.192\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.0.192\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"5\"\n            },\n            {\n                \"rtgateway\": \"61.100.1.0\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.1.0\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"6\"\n            },\n            {\n                \"rtgateway\": \"61.100.1.64\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.1.64\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"7\"\n            },\n            {\n                \"rtgateway\": \"61.100.1.128\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.1.128\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"8\"\n            },\n            {\n                \"rtgateway\": \"61.100.1.192\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.1.192\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"9\"\n            },\n            {\n                \"rtgateway\": \"61.100.2.0\",\n                \"rtusedcount\": \"0/62\",\n                \"allocationStatus\": \"0\",\n                \"nrtgateway\": \"61.101.2.0\",\n                \"nrtusedcount\": \"0/62\",\n                \"rowId\": \"10\"\n            }\n        ]\n    }\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  },
  "responseBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }
}
================================
import "@/util/getGroupIdList" as getGroupIdList;

/**
 * 管理地址 掩码
 */
var MANAGE_MASK = "32";
/**
 * 互联地址 掩码
 */
var NET_MASK = "30";
/**
 * 应用地址 掩码
 */
var APP_MASK = "26";

List listGroupId = getGroupIdList(body.groupId);

String netIpType = body.ipType;
var  page;
if (netIpType.equals(NET_MASK)) {
    //互联
    page = db.page("""
     SELECT
            sm.*,
            case when  device_alias is not null and length(device_alias)>0  then  device_alias else device_name end   deviceName
        FROM
         ndmp_ip_source_manager sm
        LEFT JOIN   ndmp_device d on d.ip=sm.ip
        WHERE        1 = 1
        <if test="body.ip != null and body.ip != ''">
            and sm.ip like concat('%', CAST(#{body.ip} AS VARCHAR),'%')
        </if>
        <if test="body.deviceName != null and body.deviceName != ''">
             and (d.device_name like concat('%', CAST(#{body.deviceName} AS VARCHAR),'%')
            or  d.device_alias like concat('%', CAST(#{body.deviceName} AS VARCHAR),'%'))
        </if>
        <if test="body.ipType != null and body.ipType != ''">
            and sm.ip_type = #{body.ipType}
        </if>
        <if test="body.usageStatus != null  ">
            and sm.usage_status = #{body.usageStatus}
        </if>
        <if test="body.allocationStatus != null ">
            and sm.allocation_Status = #{body.allocationStatus}
        </if>
        <if test="body.groupId != null ">
            and sm.group_id in
            <foreach collection="listGroupId" index="index" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        order by inet_aton(sm.ip)
    """, body.size ,body.current-1)  

  } 
else if (netIpType.equals(APP_MASK)) {
    //应用
    page = db.page("""
       SELECT rt.*,
               nrt.nrt_gateway,
               nrt.nrt_used_count
        FROM (SELECT gateway                          rt_gateway,
                     concat(SUM(usage_status), '/62') rt_used_count,
                     MAX(allocation_status) AS        allocation_status
              FROM ndmp_ip_source_manager
              WHERE real_time = 1
                AND ip_type = '26'
              GROUP BY gateway) rt
                 LEFT JOIN (SELECT gateway                          nrt_gateway,
                                   concat(SUM(usage_status), '/62') nrt_used_count,
                                   MAX(allocation_status) AS        allocation_status
                            FROM ndmp_ip_source_manager
                            WHERE real_time = 0
                              AND ip_type = '26'
                            GROUP BY gateway) nrt ON
                    substr(rt.rt_gateway, instr(rt.rt_gateway, '.', 1, 2) + 1,
                           instr(rt.rt_gateway, '.', 1, 3) - instr(rt.rt_gateway, '.', 1, 2) - 1) =
                    substr(nrt.nrt_gateway, instr(nrt.nrt_gateway, '.', 1, 2) + 1,
                           instr(nrt.nrt_gateway, '.', 1, 3) - instr(nrt.nrt_gateway, '.', 1, 2) - 1)
                and
                    substr(rt.rt_gateway, instr(rt.rt_gateway, '.', 1, 3) + 1,
                           length(rt.rt_gateway) - instr(rt.rt_gateway, '.', 1, 3)) =
                    substr(nrt.nrt_gateway, instr(nrt.nrt_gateway, '.', 1, 3) + 1,
                           length(nrt.nrt_gateway) - instr(nrt.nrt_gateway, '.', 1, 3))

        ORDER BY inet_aton(rt.rt_gateway)

    """, body.size ,body.current-1)  

  }
else {
    page = db.page("""
     SELECT
            sm.*,
        case when  device_alias is not null and length(device_alias)>0 then  device_alias else device_name end   device_name
        FROM
            ndmp_ip_source_manager sm
        LEFT JOIN   ndmp_device d on d.ip=sm.ip
        WHERE        1 = 1
        <if test="body.ip != null and body.ip != ''">
            and sm.ip like concat('%', CAST(#{body.ip} AS VARCHAR) ,'%')
        </if>
        <if test="body.deviceName != null and body.deviceName != ''">
            and (d.device_name like concat('%', CAST(#{body.deviceName} AS VARCHAR),'%')
            or  d.device_alias like concat('%', CAST(#{body.deviceName} AS VARCHAR),'%'))
        </if>
        <if test="body.ipType != null and body.ipType != ''">
            and sm.ip_type = #{body.ipType}
        </if>
        <if test="body.usageStatus != null  ">
            and sm.usage_status = #{body.usageStatus}
        </if>
        <if test="body.allocationStatus != null ">
            and sm.allocation_Status = #{body.allocationStatus}
        </if>
        <if test="body.groupId != null ">
            and sm.group_id in
            <foreach collection="listGroupId" index="index" item="id" open="(" close=")" separator=",">
                #{id}
            </foreach>
        </if>
        order by inet_aton(sm.ip)
    """,body.size ,body.current-1)  

}


//page.setRecords(list);
return page;